package com.study.reconnect;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @ClassName: ReConnectClientHandler
 * @Description:
 * @Date 2024/04/30 15:45
 * @Author songshaoqiu
 **/
public class ReConnectClientHandler extends SimpleChannelInboundHandler<String> {
    private NettyClient nettyClient;

    public ReConnectClientHandler(NettyClient nettyClient) {
        this.nettyClient = nettyClient;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
        System.out.println("读取客户端数据："+s);
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("连接断开=====断线重连中");
        nettyClient.connect();

    }
}
